package com.boot.controller.auth;

import com.boot.ao.sysrole.AddRoleAO;
import com.boot.ao.sysrole.RoleAO;
import com.boot.ao.sysrole.UpdateRoleAO;
import com.boot.common.po.Result;
import com.boot.config.auth.UserLoginToken;
import com.boot.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/role")
@Api(value = "角色管理", tags = "角色管理", description = "角色管理--接口规范")
public class RoleController extends BaseController {

    @Resource
    private RoleService roleService;

    @PostMapping("/getList")
    @UserLoginToken
    @ApiOperation(value = "获取全部数据", notes = "获取全部数据", tags = "角色管理")
    @ApiImplicitParam(name = "Authorization", value = "验证信息", dataType = "String", paramType = "header",required = true)
    public Result getList(@RequestBody RoleAO roleAO) {
        return Result.success(roleService.getList(roleAO));
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增", notes = "新增", tags = "角色管理")
    public Result add(@RequestBody AddRoleAO addRoleAO) {
        return roleService.add(addRoleAO);
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改", notes = "修改", tags = "角色管理")
    public Result update(@RequestBody UpdateRoleAO updateRoleAO) {
        return roleService.update(updateRoleAO);
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "删除", notes = "删除", tags = "角色管理")
    public Result delete(@RequestParam("id") Long id) {
        return roleService.delete(id);
    }
}
